# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Krassy Boykinov <kboykinov@teamcentrixx.com>
pkgname=libpeas2
pkgver=2.0.5
pkgrel=0
pkgdesc="GObject-based plugin system"
url="https://wiki.gnome.org/Projects/Libpeas"
# armhf blocked by gjs-dev -> mozjs
arch="all !armhf"
license="LGPL-2.1-or-later"
makedepends="
	gjs-dev
	glib-dev
	gobject-introspection-dev
	gtk+3.0-dev
	meson
	py3-gobject3-dev
	python3-dev
	vala
	"
checkdepends="dbus bash py3-gobject3 xvfb-run gobject-introspection"
subpackages="$pkgname-dev $pkgname-python3:py3 $pkgname-lang"
source="https://download.gnome.org/sources/libpeas/${pkgver%.*}/libpeas-$pkgver.tar.xz
	disable-extension-gjs-test_patch
	disable-extension-c-py_patch
	"
builddir="$srcdir/libpeas-$pkgver"

prepare() {
	default_prepare

	case "$CARCH" in
	aarch64|armv7)
		# FIXME! On aarch64 & armv7 package builders:
		# 5/6 test-extension-c   FAIL             0.96s   killed by signal 6 SIGABRT
		# 6/6 test-extension-py  FAIL             1.23s   killed by signal 6 SIGABRT
		patch tests/libpeas/meson.build "$srcdir"/disable-extension-c-py_patch
		;;
	x86*|loongarch64)
		# FIXME!
		# 4/6 test-extension-gjs FAIL             0.19s   killed by signal 11 SIGSEGV
		patch tests/libpeas/meson.build "$srcdir"/disable-extension-gjs-test_patch
		;;
	esac
}

build() {
	abuild-meson \
		-Db_lto=true \
		-Dlua51=false \
		-Dvapi=true \
		. output
	meson compile -C output
}

check() {
	xvfb-run -a meson test --print-errorlogs -C output -t 10
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

py3() {
	depends="py3-gobject3"

	amove usr/lib/libpeas-2/loaders/libpythonloader.*
}

sha512sums="
4c035b824d07c32b9bf828a9b3fed0fe842759686bd23186b1c381b6f8690ed22e6aa98c50550454593c788903c994fd0bab618c0b855970160aa135eb386e73  libpeas-2.0.5.tar.xz
5533c037dc9d9ff4f6dbb683a6433c7f6b12121143ec08e09e4f8e5232fa6058fa26c54a36577d6985ae61baa19eab1edaab1aeb6e5c1545c10de70844a0aa9b  disable-extension-gjs-test_patch
1f6429707d7259f1463d9bf12500cbf46da4811d3a57fe1d1fcc7ae4d9b76b67fc7b82e23a9e361f481e6d2bde464bc78b3a155e4aa25fd94feccc01aae152b3  disable-extension-c-py_patch
"
